<?php

//防止恶意调用
if (!defined('IN_MOD'))
{
    die('Hacking attempt');
}

// 模块参数钩子
/* 
** author 模板配置
** contenthtml 模块参数配置
*/
function hook_configmodulepara(&$configinfo=array(),$moduleid=0,$info=array(),$tpl="")
{
	$path = MODULEPARA_PATH;
	if($tpl == 1)
	{
		// 加载模板程序配置
		if($configinfo['tplok'] == 1)
		{
			$path = $configinfo['tplurl'];
		}
	}
	// 新增模板扩展配置 DATE:2020-4-28 START
	if($tpl)$configinfo['module'][$moduleid]['tpl'] = $tpl;
	// 新增模板扩展配置 DATE:2020-4-28 END
	if($info['module'])$configinfo['module'][$moduleid]['module'] = $info['module'];
	// 新增模块数据配置 DATE:2020-4-25 START
	if($info['data'])$configinfo['module'][$moduleid]['data'] = $info['data'];
	// 新增模块数据配置 DATE:2020-4-25 END
	if($info['tpl'])$configinfo['module'][$moduleid]['author'] = $info['tpl'];
	if($info['admintpl'])$configinfo['module'][$moduleid]['admintpl'] = $info['admintpl'];
	if($info['para'])
	{
		$parahtml = file_get_contents($path."/config/module/".$info['para']);
		$configinfo['module'][$moduleid]['contenthtml'] = $parahtml;
	}
		
	// 更多内容HTML-------------------------------------------
	
	if($info['morepara1'])
	{
		$moreparahtml1 = file_get_contents($path."/config/module/".$info['morepara1']);
		$configinfo['module'][$moduleid]['morecontenthtml1'] = $moreparahtml1;
	}
	
	if($info['morepara2'])
	{
		$moreparahtml2 = file_get_contents($path."/config/module/".$info['morepara2']);
		$configinfo['module'][$moduleid]['morecontenthtml2'] = $moreparahtml2;
	}
		
	if($info['morepara3'])
	{
		$moreparahtml3 = file_get_contents($path."/config/module/".$info['morepara3']);
		$configinfo['module'][$moduleid]['morecontenthtml3'] = $moreparahtml3;
	}
	
	if($info['morepara4'])
	{	
		$moreparahtml4 = file_get_contents($path."/config/module/".$info['morepara4']);
		$configinfo['module'][$moduleid]['morecontenthtml4'] = $moreparahtml4;
	}
	
	if($info['morepara5'])
	{	
		$moreparahtml5 = file_get_contents($path."/config/module/".$info['morepara5']);
		$configinfo['module'][$moduleid]['morecontenthtml5'] = $moreparahtml5;
	}
	
	//--------------------------------------------------------END

	if($info['addpara'])
	{
		$addparahtml = file_get_contents($path."/config/module/".$info['addpara']);
		$configinfo['module'][$moduleid]['contenthtml'] .= $addparahtml;
	}
		
	// 更多内容HTML-------------------------------------------
		
	if($info['moreaddpara1'])
	{
		$moreaddparahtml1 = file_get_contents($path."/config/module/".$info['moreaddpara1']);
		$configinfo['module'][$moduleid]['morecontenthtml1'] .= $moreaddparahtml1;
	}
	
	if($info['moreaddpara2'])
	{	
		$moreaddparahtml2 = file_get_contents($path."/config/module/".$info['moreaddpara2']);
		$configinfo['module'][$moduleid]['morecontenthtml2'] .= $moreaddparahtml2;
	}
	
	if($info['moreaddpara3'])
	{	
		$moreaddparahtml3 = file_get_contents($path."/config/module/".$info['moreaddpara3']);
		$configinfo['module'][$moduleid]['morecontenthtml3'] .= $moreaddparahtml3;
	}
	
	if($info['moreaddpara4'])
	{	
		$moreaddparahtml4 = file_get_contents($path."/config/module/".$info['moreaddpara4']);
		$configinfo['module'][$moduleid]['morecontenthtml4'] .= $moreaddparahtml4;
	}
	
	if($info['moreaddpara5'])
	{	
		$moreaddparahtml5 = file_get_contents($path."/config/module/".$info['moreaddpara5']);
		$configinfo['module'][$moduleid]['morecontenthtml5'] .= $moreaddparahtml5;
	}
		
	//--------------------------------------------------------END

	if($info['parafun'])
	{
		$parafunhtml = file_get_contents($path."/config/module/".$info['parafun']);
		$configinfo['module'][$moduleid]['contentfunhtml'] = $parafunhtml;
	}
	if($info['addparafun'])
	{
		$addparafunhtml = file_get_contents($path."/config/module/".$info['addparafun']);
		$configinfo['module'][$moduleid]['contentfunhtml'] .= $addparafunhtml;
	}
	if($info['sitepara'])
	{
		$siteparahtml = file_get_contents($path."/config/module/".$info['sitepara']);
		$configinfo['module'][$moduleid]['contentmobilehtml'] = $siteparahtml;
	}
	// 新增小程序前台模块参数信息 DATE：2019-12-25 START
	if($info['xcxsitepara'])
	{
		$xcxsiteparahtml = file_get_contents($path."/config/module/".$info['xcxsitepara']);
		$configinfo['module'][$moduleid]['xcxcontentmobilehtml'] = $xcxsiteparahtml;
	}
	// 新增小程序前台模块参数信息 DATE：2019-12-25 END
}

// 模块其它参数钩子
/* 
** author_email 列表关联数据配置
** description 列表搜索配置
** link 列表搜索条件字段配置
** content 模块参数字段名称配置
** contentmobile 列表模块参数显示配置
** contentmobilehtml 前台模块参数配置
** xcxcontentmobilehtml 小程序前台模块参数配置
** columnpara 前台自定义栏目参数配置
** feedbackok 反馈模块配置
*/
function hook_configmoduleparaother(&$configinfo=array(),$moduleid=0,$info=array(),$tpl="")
{
	$path = MODULEPARA_PATH;
	if($tpl == 1)
	{
		// 加载模板程序配置
		if($configinfo['tplok'] == 1)
		{
			$path = $configinfo['tplurl'];
		}
	}
	// 新增模板扩展配置 DATE:2020-4-28 START
	if($tpl)$configinfo['module'][$moduleid]['tplother'] = $tpl;
	// 新增模板扩展配置 DATE:2020-4-28 END
	if($info['attrlist'])$configinfo['module'][$moduleid]['author_email'] = $info['attrlist'];
	if($info['searchhtml'])
	{
		$searchhtml = file_get_contents($path."/config/module/".$info['searchhtml']);
		$configinfo['module'][$moduleid]['description'] = $searchhtml;
	}
	if($info['searchfield'])$configinfo['module'][$moduleid]['link'] = $info['searchfield'];
	if($info['pname'])$configinfo['module'][$moduleid]['content'] = $info['pname'];
	if($info['rpname'])$configinfo['module'][$moduleid]['rcontent'] = $info['rpname'];
	if($info['ptitle'])$configinfo['module'][$moduleid]['contentmobile'] = $info['ptitle'];
	if($info['pvalue'])$configinfo['module'][$moduleid]['pvalue'] = $info['pvalue'];
	if($info['listdatahtml'])$configinfo['module'][$moduleid]['listdatahtml'] = file_get_contents($path."/config/module/".$info['listdatahtml']);
	if($info['listexphtml'])$configinfo['module'][$moduleid]['listexphtml'] = file_get_contents($path."/config/module/".$info['listexphtml']);
	if($info['contentexphtml'])$configinfo['module'][$moduleid]['contentexphtml'] = file_get_contents($path."/config/module/".$info['contentexphtml']);
	if($info['columnpara'])
	{
		$columnparahtml['type1'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type1.html");
		$columnparahtml['type2'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type2.html");
		$columnparahtml['type3'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type3.html");
		$columnparahtml['type4'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type4.html");
		$columnparahtml['type5'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type5.html");
		$columnparahtml['type6'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type6.html");
		$columnparahtml['type0'] = file_get_contents($path."/config/module/".$info['columnpara']."/columnpara/type0.html");
		$configinfo['module'][$moduleid]['columnparahtml'] = $columnparahtml;
	}
	if($info['feedbackok'])$configinfo['module'][$moduleid]['feedbackok'] = $info['feedbackok'];
	if($info['parafieldpri'])$configinfo['module'][$moduleid]['parafieldpri'] = $info['parafieldpri'];
}

// 模块更多配置
function hook_configmoduleparamore(&$configinfo=array(),$modname='',$moduleid=0,$infodatagroup=array(),$tpl=0)
{
	$notempty = 0;
	foreach($infodatagroup as $key=>$val)
	{
		if(is_array($val))
		{
			foreach($val as $k=>$v)
			{
				if(is_array($v))
				{
					foreach($v as $k3=>$v3)
					{
						if(!empty($v3))
						{
							$notempty = 1;
						}else{
							unset($infodatagroup[$key][$k][$k3]);		
						}
					}
				}else{
					if(!empty($v))
					{
						$notempty = 1;
					}else{
						unset($infodatagroup[$key][$k]);	
					}
				}
			}
		}else{
			if(!empty($val))
			{
				$notempty = 1;
			}else{
				unset($infodatagroup[$key]);		
			}
		}
	}
	if($notempty == 1)
	{
		if($tpl == 1)
		{
			// 判断是否多维数组 判断一个数组是一维数组或者是二维数组或多维数组
			if(count($infodatagroup) == count($infodatagroup, 1))
			{
				$configinfo[$modname."_module"][$moduleid] = array_merge($configinfo[$modname."_module"][$moduleid], $infodatagroup);
			}else{
				foreach($infodatagroup as $key=>$val)
				{
					$configinfo[$modname."_module"][$moduleid][$key] = array_merge($configinfo[$modname."_module"][$moduleid][$key], $val);
				}
			}
		}else{
			$configinfo[$modname."_module"][$moduleid] = $infodatagroup;
		}
	}
}

// 多图上传钩子
//echo hook_duopicupload();
//echo hook_duopicupload("test",2);
//echo hook_duopicupload("aaa",5);
function hook_duopicupload($dataname = "",$num=1,$fieldvalue = "")
{
	$upload = "";
	
	$upload .='<div class="duopicmain">';
	$upload .='	<div class="showdata">';
	$upload .='		<ul id="showui'.$dataname.'">';
	if($fieldvalue)
	{
		$fieldvaluearr = getstrtoarr(',', $fieldvalue);
		foreach($fieldvaluearr as $key=>$imgurl)
		{
			$upload .='			<li>
									<div class="showdiv">
										<img class="left" src="/plugins/modulepara/configdata/images/moduleindex/Arrow_left.svg">
										<img class="center" src="/plugins/modulepara/configdata/images/moduleindex/delete.svg">
										<img class="right" src="/plugins/modulepara/configdata/images/moduleindex/Arrow_right.svg">
									</div>
									<img id="srcimgid'.$key.'" class="showimg" src="'.$imgurl.'">
								</li>';
		}
	}
	$upload .='		</ul>';
	$upload .='		<div id="showinput'.$dataname.'">';
	$upload .='		</div>';
	$upload .='	</div>';
	$upload .='	<div class="upimg">';
	$upload .='		<input type="file" id="upgteimg'.$dataname.'" value="" multiple />';
	$upload .='	</div>';
	$upload .='</div>';
	$upload .='<script>$(function(){st_upduoimg("'.$dataname.'","'.$num.'","'.$fieldvalue.'");});</script>';
	
	return $upload;
}

// 图片上传钩子
function hook_uploadpic($dataname = "", $fieldname = "", $fieldvalue = "", $phpurl = "", $buttonname = "上传")
{
	global $configinfo;
	
	$uploadphpurl = $phpurl ? $phpurl : $configinfo['uploadphpurl'];
	
	$upload = "";
	
	$upload .='<div class="picUpload">
		<div class="uppic"><input name="'.$fieldname.'" id="uploadFile'.$dataname.'" value="'.$fieldvalue.'" readonly /></div>
		<div class="fileUpload">
			<input id="uploadBtn'.$dataname.'" type="file" class="upload" />
			<span>'.$buttonname.'</span>
		</div>';
	if($fieldvalue)
	{
		$upload .='<p><img src="'.$configinfo['uploadurl'].$fieldvalue.'" id="imgPath'.$dataname.'" class="imgPath"></p>';
	}else{
		$upload .='<p><img src="'.$fieldvalue.'" id="imgPath'.$dataname.'" class="imgPath" style="display: none"></p>';	
	}
	$upload .='</div>
	<script>$(function(){st_uploadpic("'.$dataname.'","'.$uploadphpurl.'","'.$configinfo['uploadurl'].'");});</script>';
	
	return $upload;
}

// 文件上传钩子
function hook_uploadfile($dataname = "",$module = "article", $fieldname = "", $fieldvalue = "")
{
	global $configinfo;
	
	$topmodule_upconfiginfo = gettopmodule($module,"uploadconfig");
	$upconfiginfo = $topmodule_upconfiginfo;
	
	$upload = "";
	
	$showImgHtml = "";
	$showFileHtml = "";
	if($fieldvalue)
	{
		if(isUrlImage($fieldvalue))
		{
			$showImgHtml = '<p class="picShow" style="margin-bottom:0; margin-top:10px;"><a href="'.$configinfo['uploadurl'].$fieldvalue.'" target="_blank">
				<img src="'.$configinfo['uploadurl'].$fieldvalue.'" id="imgPath'.$dataname.'" style="max-width:520px;"></a></p>';	
		}else{
			$showFileHtml = '<a class="fileShow" href="'.$configinfo['uploadurl'].$fieldvalue.'" target="_blank" style="height:35px; line-height:35px; padding-left:10px; display:block; float:left;">查看文件</a>';	
		}	
	}
	
	$upload .='<div class="uploadcontent" id="uploadcontent'.$dataname.'">
		<div class="upload">
			<!--文件选择按钮-->
			<a class="uploadInput" href="javascript:;">
				<input id="videofile'.$dataname.'" type="file" name="myvideofile" />
				<span class="videoName"></span>
				<!--预览框-->
				<div class="preview">
					<span>'.$fieldvalue.'</span>
					<input type="hidden" id="upfileurl'.$dataname.'" name="'.$fieldname.'" value="'.$fieldvalue.'" />
				</div>
			</a> 
			<button class="upbut" type="button">上传</button>
			'.$showFileHtml.'
			<div class="el-progress__text" style="font-size: 18px; display:none;">0%</div>
			<div style="clear:both"></div>
			'.$showImgHtml.'
		</div>
	  
		<!--进度条-->
		<div class="el-progress el-progress--line" style="display: none;">
			<div class="el-progress-bar">
				<div class="el-progress-bar__outer" style="height: 6px;">
					<div class="el-progress-bar__inner" style="width: 0%;">
					</div>
				</div>
			</div>
			<!--上传速度显示-->
			<span class="time"></span> 
		</div>
	</div>
	<script>$(function(){st_uploadfile("'.$dataname.'","'.$upconfiginfo['phpurl'].'");});</script>';
	
	return $upload;
}

// 四级级联分类钩子
function hook_cascade4cate($dataname=0,$cityclass='',$selectname=array(),$selectval=array(),$noempty="",$selectclass="")
{
	$catedata = "";
	
	if($selectname[0])$catedata .= "<select class='".$selectclass."' id='jlselect1_".$dataname."' name='".$selectname[0]."' ".$noempty." autocomplete='off'></select>&nbsp;&nbsp;";
	if($selectname[1])$catedata .= "<select class='".$selectclass."' id='jlselect2_".$dataname."' name='".$selectname[1]."' ".$noempty." autocomplete='off'></select>&nbsp;&nbsp;";
	if($selectname[2])$catedata .= "<select class='".$selectclass."' id='jlselect3_".$dataname."' name='".$selectname[2]."' ".$noempty." autocomplete='off'></select>&nbsp;&nbsp;";
	if($selectname[3])$catedata .= "<select class='".$selectclass."' id='jlselect4_".$dataname."' name='".$selectname[3]."' ".$noempty." autocomplete='off'></select>&nbsp;&nbsp;";	
	
	$catedata .= "<script type='text/javascript'>
	$(function(){
		var data".$dataname." = '".$cityclass."';
		var fourSelectData".$dataname." = eval('('+data".$dataname."+')');
	
		var defaults".$dataname." = {
			s1: 'jlselect1_".$dataname."',
			s2: 'jlselect2_".$dataname."',
			s3: 'jlselect3_".$dataname."',
			s4: 'jlselect4_".$dataname."',
			v1: '".$selectval[0]."',
			v2: '".$selectval[1]."',
			v3: '".$selectval[2]."',
			v4: '".$selectval[3]."'
		};
		
		fourSelect(defaults".$dataname.",fourSelectData".$dataname.");
	});
    </script>";
	
	return $catedata;
}

// 验证码钩子
function hook_moduleimgcode($url='')
{
	$moduleimgcode = '<img  title="点击刷新" src="'.$url.'" align="absbottom" 
	onClick="this.src=\"/app/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=article&ajaxname=moduleimgcode&\"+Math.random();"></img>';
	
	return $moduleimgcode;
}

// 后台自定义模块参数分类标题html
function hook_getcolumnparameterclasshtml($data=array())
{
	global $configinfo;
	global $supplier_id;
	
	// 获取商家配置模块栏目参数信息
	$data['supplier'] = 0;
	if($supplier_id)
	{
		$data['supplier'] = 1;
	}
	
	$supplier = $data['supplier'];
	$parahtml = "";
	
	// 前台模块参数
	if($configinfo['modulepara'] != "admin")
	{
		$parahtml = modulehook("getcolumnparameterclasshtmlsite",array('data'=>$data));
	
	// 后台模块参数
	}else{
		$parahtml = hook_getcolumnparameterclasshtmladmin($data);
	}
	
	// 商家模块参数
	if($supplier == 1)
	{
		// 前台模块参数
		if($configinfo['modulepara'] != "admin")
		{
			$parahtml = hook_getcolumnparameterclasshtmlsupplieruser($data);
			
		// 后台模块参数
		}else{
			$parahtml = hook_getcolumnparameterclasshtmlsupplier($data);
		}
	}
	
	return $parahtml;
}

// 后台自定义模块参数html
function hook_getcolumnparameterhtml($data=array())
{
	global $configinfo;
	
	$supplier = $data['supplier'];
	$parahtml = "";
	
	// 获取自定义栏目参数HTML
	$columnparahtml = getcolumnparahtml($configinfo['moduleid']);
	
	// 前台模块参数
	if($configinfo['modulepara'] != "admin")
	{
		$parahtml = modulehook("getcolumnparameterhtmlsite",array('data'=>$data,'columnparahtml'=>$columnparahtml));
	
	// 后台模块参数
	}else{
		// 【模块参数后台程序模板安装】反馈模块配置
		if($configinfo['topmodule']['feedbackok'] == 1)
		{
			$parahtml = hook_getcolumnparameterhtmladminfeedback($data,$columnparahtml);
		}else{
			$parahtml = hook_getcolumnparameterhtmladmin($data,$columnparahtml);	
		}
	}
	
	// 商家模块参数
	if($supplier == 1)
	{
		// 前台模块参数
		if($configinfo['modulepara'] != "admin")
		{
			$parahtml = hook_getcolumnparameterhtmlsupplieruser($data,$columnparahtml);
			
		// 后台模块参数
		}else{
			$parahtml = hook_getcolumnparameterhtmlsupplier($data,$columnparahtml);	
		}
	}
	
	return $parahtml;
}

// 栏目模块参数搜索html
function hook_getsearchparameterhtml($data=array(),$configlang=array())
{		
	$type = $data['type'];
	$parahtml = "";
	
	if($type == 7)
	{
		$orderok_desc = $data['orderselect_desc'] ? "selecton" : "";
		$orderok_asc = $data['orderselect_asc'] ? "selecton" : "";
		
		$parahtml = '<dl>
					  <dt>'.$data['title'].'</dt>
					  <dd>
					  <div class="leftinfo">';
		foreach($data['attrinfo'] as $key=>$val)
		{
			$info = $val['infomin']." ~ ".$val['infomax'];
			$selectok = $val['select'] ? "selecton" : "";
			$parahtml .= '<a href="'.$val['url'].'" class="'.$selectok.'">'.$info.'</a>';
		}
		$parahtml .= '</div>
					  <div class="rightinfo">
                  	  <input class="minnumber" type="number" value="'.$data['minnumber'].'"> ~ <input class="maxnumber" type="number" value="'.$data['maxnumber'].'">
					  <input type="submit" value="'.$configlang['submit'].'" class="st-curp" onclick="numberpara_'.$data['id'].'(this)">
					  <div class="orderfs"><span>'.$configlang['Sort_by'].'：</span><a href="'.$data['orderurl_desc'].'" class="'.$orderok_desc.'">'.$configlang['inverted'].'</a> - <a href="'.$data['orderurl_asc'].'" class="'.$orderok_asc.'">'.$configlang['positive'].'</a></div>
					  </div>
					  <script>
					  function numberpara_'.$data['id'].'(that){
							var minnumber = $(that).parent().find(".minnumber").val();
							var maxnumber = $(that).parent().find(".maxnumber").val();
							var url = "'.$data['url'].'";
							var searchurl = "'.$data['searchurl'].'" + minnumber + "-" + maxnumber + "";
							location.href = url + searchurl;
					  }
					  </script>
					  </dd>
					</dl>';
	}else{
		$parahtml = '<dl>
					  <dt>'.$data['title'].'</dt>
					  <dd>';
		foreach($data['attrinfo'] as $key=>$val)
		{
			$selectok = $val['select'] ? "selecton" : "";
			$parahtml .= '<a href="'.$val['url'].'" class="'.$selectok.'">'.$val['info'].'</a>';
		}	  
		$parahtml .= '</dd>
					</dl>';	
	}
		
	return $parahtml;
}

// 后台商品模块参数html
function hook_getadminshopparameterhtml($data=array(),$otherdata=array())
{
	global $configinfo;
	global $supplier_id;
	
	// 获取商家配置模块栏目参数信息
	$otherdata['supplier'] = 0;
	if($supplier_id)
	{
		$otherdata['supplier'] = 1;
	}
	
	$supplier = $otherdata['supplier'];
	$parahtml = "";
	
	// 后台模块参数
	if($configinfo['modulepara'] == "admin")
	{
		$parahtml = hook_getadminshopparameterhtmladmin($data,$otherdata);
	}
	
	// 商家模块参数
	if($supplier == 1)
	{
		// 前台模块参数
		if($configinfo['modulepara'] != "admin")
		{
			$parahtml = hook_getadminshopparameterhtmlsupplieruser($data,$otherdata);
			
		// 后台模块参数
		}else{
			$parahtml = hook_getadminshopparameterhtmlsupplier($data,$otherdata);
		}
	}

	return $parahtml;
}

// 商品模块参数html
function hook_getshopparameterhtml($data=array(),$otherdata=array(),$configlang=array())
{
	global $configinfo;

	$parahtml = '<div class="iteminfo_buying">
				<form method="post" id="formcart">
					<!--规格属性-->
					<div class="sys_item_spec">';
		foreach($data as $key=>$val)
		{
			$parahtml .= '<dl class="shop-clearfix iteminfo_parameter sys_item_specpara">
							<dt>'.$val['title'].'</dt>
							<dd>
								<ul class="sys_spec_text">';
									$attrlisti = 0;
					foreach($val['attrlist'] as $key2=>$val2)
					{
						$attrlisti++;
						$checkok = $attrlisti == 1 ? "checked" : "";
						$selectedok = $attrlisti == 1 ? "selected" : "";
						$parahtml .= '    <li class="'.$selectedok1.'"><a href="javascript:;" title="'.$val2.'"><label><input onclick="specoperlist()" data-specid="'.$key2.'" name="goodsattr_'.$val['id'].'" type="radio" class="radio" value="'.$val2.'" '.$checkok1.' style="">'.$val2.'</label></a><i></i></li>';
					}
				   $parahtml .= '</ul>
							</dd>
						</dl>';
		}
		foreach($otherdata['goodsspecinfo'] as $key=>$val)
		 {
			foreach($val as $key2=>$val2)
			{
				$parahtml .= '<input type="hidden" id="shoppara_'.$key.'_'.$key2.'" value="'.$val2.'" />';
			}
		 }
		 // 当前商品为积分商品时禁止设置购买数量
		 if($otherdata['integralgoods'] == 1)
		 {
			 $parahtml .= '<input type="hidden" name="goodsnumber" id="shopnum_val" value="1">';
		 }else{
						$parahtml .= '<dl class="shop-clearfix iteminfo_parameter lh32" style="border-top:1px solid #ddd; margin-top:10px; padding-top:15px;">
										<dt>购买数量</dt>
										<dd>
											<div class="shopnumbox">
											  <input type="text" name="goodsnumber" id="shopnum_val" value="1" onchange="checknum(this)">
											  <div id="shopnum_increase"></div>
											  <div id="shopnum_decrease"></div>
											</div>
											<div class="st-clear"></div>
										</dd>
									</dl>';
		}
						$parahtml .= '<dl class="shop-clearfix iteminfo_parameter lh32 showDetailMainB" style="border-top:1px solid #ddd; margin-top:10px; padding-top:15px;">
										<dd style="margin-left:-55px;">';
							// 当前商品为积分商品时设置积分+余额价格
							if($otherdata['integralgoods'] == 1)
							{
								$parahtml .= '<a id="addtocart" class="showDetailZxgm" href="javascript:;"><span></span>去购物车结算</a>
								<span style="display:inline-block; margin-left:10px; margin-top:5px;"><font style="font-size:16px; color:red;"><span id="totalintegral">0</span>积分</font>
								+
								<font style="font-size:16px; color:red;">￥<span id="totalprice">0</span></font></span>';
							}else{
								$parahtml .= '<a id="addtocart" class="showDetailZxgm" href="javascript:;"><span></span>'.$configlang['Add to cart'].'</a>
								<span style="display:inline-block; margin-left:10px;">总价：<font style="font-size:22px; color:red;">￥<span id="totalprice">0</span></font></span>';	
							}
							$parahtml .= '<span id="kucunshow" style="display:inline-block; margin-left:10px; display:none;">库存：<font><span id="totalnumber">0</span>件</font></span>
											<input type="hidden" id="goodsid" name="goodsid" value="'.$otherdata['dataid'].'">
											<input type="hidden" id="columnid" name="columnid" value="'.$otherdata['columnid'].'">
										</dd>
									</dl>
					  </div>
					<!--规格属性-->
				</form>
				</div>
				  <div id="overlay" style="margin: 0px; padding: 0px; border: none; width: 100%; height: 100%; background: rgb(51, 51, 51); opacity: 0.6; z-index: 9999; position: fixed; top: 0px; left: 0px; display: none;"></div>
				  <div id="easyDialogBox" style="margin: -118px 0px 0px -243px; padding: 0px; border: none; z-index: 10000; position: fixed; top: 50%; left: 50%; display: none;">
					<div class="add_ok" id="cart_show" style=" margin: 0px; display:block">
						<div class="tip">
							<img src="/plugins/modulepara/configdata/images/ok.png" style="vertical-align:middle" /> 商品已成功加入购物车
						</div>
						<div class="go">
							<a onclick="hidetip()" class="back st-curp">&lt;&lt;继续购物</a>
							<a href="'.$otherdata['shopmoduleurl'].'" class="flowbtn">去结算</a>
						</div>
					</div>
				  </div>
				<script>
				  //商品规格选择
					$(function(){
						$(".sys_item_spec .sys_item_specpara").each(function(){
							var i=$(this);
							var p=i.find("ul>li");
							p.click(function(){
								$(this).addClass("selected").siblings("li").removeClass("selected");
							})
						})
					})
					totalprice();
				  $("#shopnum_increase").click(function(){
						var number = Number($("#shopnum_val").val()) + Number(1);
						$("#shopnum_val").val(number);
						totalprice();
				  });
				  $("#shopnum_decrease").click(function(){
					 if($("#shopnum_val").val() > 1){
						 var number = Number($("#shopnum_val").val()) - Number(1);
						 $("#shopnum_val").val(number);
						 totalprice();
					 }
				  });
				  function checknum(t){
					if($(t).val() < 1 || !$.isNumeric($(t).val())){
						$("#shopnum_val").val(1);	
					}  
					totalprice();
				  }
				  function specoperlist(){
					  totalprice();
				  }
				  function totalprice(){
					var number = $("#shopnum_val").val();	
					
					var selectspeclist = $(".sys_spec_text input[type=radio]:checked");
					var namegroup = "";
					$.each(selectspeclist, function () {
						namegroup += $(this).data("specid") + "-";
					});
					namegroup = namegroup.substr(0, namegroup.length - 1);
					var integral = $("#shoppara_integralson_"+namegroup).val();// 积分兑换
					var price = $("#shoppara_priceson_"+namegroup).val();
					var kucun = $("#shoppara_countson_"+namegroup).val();
					
					if(integral || price){
						var totalintegral = Number(number) * Number(integral);// 积分兑换
						$("#totalintegral").html(totalintegral);// 积分兑换
						var totalprice = Number(number) * Number(price);
						$("#totalprice").html(totalprice);
						$("#totalnumber").html(kucun);
						$("#kucunshow").show();
					}else{
						$("#totalintegral").html($("#integralprice").html());// 积分兑换
						$("#totalprice").html($("#goodsprice").html());	
					}
				  }
				  function hidetip(){$("#overlay").hide();$("#easyDialogBox").hide();}
				  $("#addtocart").click(function(){
					  var goodsid = $("#goodsid").val();
					  var columnid = $("#columnid").val();
					  var postdata = $("#formcart").serializeArray();
					  var postdatagroup = {};
					  $.each(postdata, function(i, field){
						postdatagroup[field.name] = field.value;
					  });
					  console.log(postdatagroup);
					  $.post("'.$otherdata['shopcarturl'].'",{ajaxmember:"ok",ajaxid:goodsid,ajaxname:"addcart",columnid:columnid,postdata:postdatagroup},function(data){
							var data=eval(\'(\'+data+\')\');
							console.log(data);
							if(data.error == 0){
								var content = data.content;
								$("#overlay").show();		
								$("#easyDialogBox").show();		
								$("#cartnumber").html(content.cartnumber);
							}else if(data.error == 2){
								Wind.use("noty", function () {
									noty({
										text: data.message,
										type: "error",
										layout: "center",
										callback: {
											afterClose: function () {
												location.href="/user/login/index.html";
											}
										}
									});
								});
							}else{
								Wind.use("noty", function () {
									noty({
										text: data.message,
										type: "error",
										layout: "center"
									});
								});
							}
							
					  });
				  });
				  </script>';
					
	return $parahtml;
}

// 商品活动列表html
function hook_getshopactivityhtml($activitylist=array(),$otherdata=array(),$configlang=array())
{
	global $configinfo,$configmember;
	
	$hdtype_name = getdesignatedname("hdtype");
	$tomoney_name = getdesignatedname("tomoney");
	$endtime_name = getdesignatedname("datetype_endtime");

	$parahtml = '<h3 class="hdtitle">优惠促销</h3>';
				  if(!empty($activitylist['couponlist']))
				  {
					  $parahtml .= '<dl class="receive-quan">
									  <dd>';
					  foreach($activitylist['couponlist'] as $key=>$val)
					  {
						if($key < 2 )
						{
							$parahtml .= '<a class="p-quan2" title="'.$val['post_title'].'" href="javascript:;">
											<i class="quan-border bl"></i><span>¥10</span><i class="bm"></i><span class="p-quan-white">满'.$val[$tomoney_name].'用'.$val['yhmoney'].'</span><i class="quan-border br"></i>
											</a>';
						}
					  }
							 $parahtml .= '<a href="javascript:;" class="st-openSelect">共'.$activitylist['couponcount'].'张优惠券&gt;</a>
											<div class="st-selectBlock" style="z-index:9999;">
												<div class="st-selectBox" style="width:270px;background:#eee;">
													<div class="st-titBox">领取优惠券</div>
													<ul class="stamp_list">';
						foreach($activitylist['couponlist'] as $key=>$val)
						{
										$hdtype = $val[$hdtype_name] == 1 ? "指定商品优惠券" : "订单优惠券";
										$mycoupon = $configmember['couponlist'][$val['id']] ? "您<br>已<br>领<br>取" : "立<br>即<br>领<br>取";
										$parahtml .= '<li class="stamp">
														<div class="stamp_inner stamp_left">
														  <ul>
															<li><span><em>￥</em>'.$val['yhmoney'].'</span> '.$hdtype.'
															<li>'.$val['post_title'].'</li>
															<li class="status-text-yellow">满'.$val[$tomoney_name].'元可用<li>
															<li class="status-text-gray">有效期：'.date('Y-m-d',$val[$endtime_name]).'</li>
														  </ul>
														</div
														><div class="stamp_inner stamp_right">
															<span class="addyouhuijuan" data-id="'.$val['id'].'">'.$mycoupon.'</span>
															<ul class="circle_list circle_list1">
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
															</ul>
														</div>
													</li>';
						}
									$parahtml .= '</ul>
													<div class="st-titBox">我的优惠券</div>
													<ul class="stamp_list">';
						foreach($configmember['couponlist'] as $key=>$val)
						{
										$hdtype = $val[$hdtype_name] == 1 ? "指定商品优惠券" : "订单优惠券";
										$parahtml .= '<li class="stamp">
														<div class="stamp_inner stamp_left">
														  <ul>
															<li><span><em>￥</em>'.$val['yhmoney'].'</span> '.$hdtype.'
															<li>'.$val['name'].'</li>
															<li class="status-text-yellow">满'.$val['tomoney'].'元可用<li>
															<li class="status-text-gray">有效期：'.date('Y-m-d',$val['endtime']).'</li>
														  </ul>
														</div
														><div class="stamp_inner stamp_right">
															<a href="'.$val['url'].'" class="st-disb"><span>尽<br>快<br>使<br>用</span></a>
															<ul class="circle_list circle_list1">
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
																<li></li>
															</ul>
														</div>
													</li>';
						  }
						  if(empty($configmember['couponlist']))
						  {
							 		  $parahtml .= '<li class="stamp">暂无任何优惠券！</li>';
						  }
									$parahtml .= '</ul>
												</div>
												<div class="st-bgBox"></div>
											</div>
										  </dd>
										</dl>';
						$parahtml .= '<script>
								  $(".addyouhuijuan").click(function(){
									  var that = this;
									  var yhjid = $(this).data("id");
									  $.post("/portal/Ajax/index.html",{ajaxmember:"ok",ajaxid:yhjid,ajaxname:"addyouhuijuan"},function(data){
											var data=eval(\'(\'+data+\')\');
											console.log(data);
											if(data.error == 0){
												alert(data.message);
												$(that).html("您<br>已<br>领<br>取");
											}else if(data.error == 2){
												Wind.use("noty", function () {
													alert(data.message);
													location.href="/user/login/index.html";
												});
											}else{
												alert(data.message);
											}
									  });
								  });
								  </script>';
				    }
					if(!empty($activitylist['activity_less_list']) || !empty($activitylist['activity_dis_list']))
					{
	  					$parahtml .= '<div class="proinfo-promo">
										<ul>';
						if(!empty($activitylist['activity_less_list']))
						{
							$parahtml .= '<li class="promo-list">
											<label>满 减</label>
											<i class="i-triangle"></i>
											<div class="promotion-content">
											<span>';
										  foreach($activitylist['activity_less_list'] as $key=>$val)
										  {
											$parahtml .= '<a style="color:#f60;" href="javascript:;" title="'.$val['post_title'].'">满'.$val[$tomoney_name].'元减'.$val['yhmoney'].'元，</a>';
										  }  
							$parahtml .= '</span>
										  <a href="javascript:;" class="showhddesc">展开<i class="fa fa-angle-down"></i></a>
										 </div>
										</li>';
						}
						if(!empty($activitylist['activity_dis_list']))
						{
							$parahtml .= '<li class="promo-list">
								<label>折 扣</label>
								<i class="i-triangle"></i>
								<div class="promotion-content">
								<span>';
							  foreach($activitylist['activity_dis_list'] as $key=>$val)
							  {
								$parahtml .= '<a style="color:#f60;" href="javascript:;" title="'.$val['post_title'].'">满'.$val[$tomoney_name].'元打'.$val['expression'].'折，</a>';
							  }  
						$parahtml .= '</span>
							  <a href="javascript:;" class="showhddesc">展开<i class="fa fa-angle-down"></i></a>
							 </div>
							</li>';
						}
						$parahtml .= '</ul>
									</div>';
						$parahtml .= '<script>
								  $(".showhddesc").click(function(){
									  if($(this).prev().css("height")=="20px"){
										  $(this).prev().css("height","auto");
										  $(this).find("i").addClass("fa-angle-up").removeClass("fa-angle-down");
									  }else{
										  $(this).prev().css("height","20px");
										  $(this).find("i").addClass("fa-angle-down").removeClass("fa-angle-up"); 
									  }
								  });
								  </script>';
				  }
					
	return $parahtml;
}

// 商品购物车HTML
function hook_getshopcarthtml($cartnumber=0)
{
	global $configinfo;
	
	$carthtml = '<div class="cartBox">
	  <a href="/list108-cn.html">
		  <i class="fa fa-shopping-cart"></i>
		  <span>去购物车结算</span>
		  <span class="num" id="cartnumber">'.$cartnumber.'</span>
	  </a>
	</div>';
	
	return $carthtml;
}

// 后台栏目模块参数搜索html
function hook_getsearchparameterhtml2($data=array())
{
	$type = $data['type'];
	$parahtml = "";
	
	// 下拉
	if($type == 1)
	{
		$parahtml = '<dl>
					  <dt>'.$data['title'].'</dt>
					  <dd>
					  <select class="form-control" name="searchpara['.$data['id'].']">
						  <option value="0">请选择列表</option>';
		foreach($data['attrinfo'] as $key=>$val)
		{			  
			$parahtml .= '<option value="'.$val['info'].'" '.$val['select'].'>'.$val['info'].'</option>';
		}
		$parahtml .= ' </select>
					  </dd>
					</dl>';
		
	// 多选	
	}else if($type == 3)
	{
		$parahtml = '<dl>
					  <dt>'.$data['title'].'</dt>
					  <dd>';
		foreach($data['attrinfo'] as $key=>$val)
		{			  
			$parahtml .= '<label class="st-inputBox" for="attrpara_'.$data['id'].'_'.$val['id'].'" style="color:#666"><input name="searchpara['.$data['id'].']['.$val['id'].']" type="checkbox" value="'.$val['info'].'" id="attrpara_'.$data['id'].'_'.$val['id'].'" '.$val['select'].' /> <span>'.$val['info'].'</span></label>&nbsp;&nbsp;';
		}		  
		$parahtml .= '</dd>
					</dl>';
		
	// 单选	
	}else if($type == 5)
	{
		$parahtml = '<dl>
					  <dt>'.$data['title'].'</dt>
					  <dd>';
		foreach($data['attrinfo'] as $key=>$val)
		{			  
			$parahtml .= '<label class="st-inputBox" for="attrpara_'.$data['id'].'_'.$val['id'].'" style="color:#666"><input name="searchpara['.$data['id'].']" type="radio" value="'.$val['info'].'" id="attrpara_'.$data['id'].'_'.$val['id'].'" '.$val['select'].' /> <span>'.$val['info'].'</span></label>&nbsp;&nbsp;';
		}		  
		$parahtml .= '</dd>
					</dl>';

	
	// 数字		
	}else{
		
		$parahtml = '<dl class="numberpara">
					  <dt>'.$data['title'].'</dt>
					  <dd>';	  
		$parahtml .= '<input name="searchpara['.$data['id'].'][sn|0]" type="number" value="'.$data['minnumber'].'"> ~ <input name="searchpara['.$data['id'].'][sn|1]" type="number" value="'.$data['maxnumber'].'">
					  </dd>
					</dl>';
	}
		
	return $parahtml;
}

/* 获取区块HTML钩子 */
function hook_getblockhtml($fileurl='',$data=array(),$tpl=0)
{
	global $configinfo,$configlang;
	
	$path = MODULEPARA_PATH;
	if($tpl == 1)
	{
		// 加载模板程序配置
		if($configinfo['tplok'] == 1)
		{
			$path = $configinfo['tplurl'];
		}
	}
	
	$openfilehtml = file_get_contents($path."/config/block/".$fileurl);
	$reshtml = phpvarok($openfilehtml,$configlang,$data[0],$data[1],$data[2]);
	
	return $reshtml;	
}
?>